<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>基础类型数据-Boolean</title>
  </head>
  <body>
    <script>
      
      // 字面量声明
      //   var a = true;
      //   b = false;
      //   console.log(a, b);   //true false

      //   var str1 = "wdnfk";
      //   var str2 = "";
      //   console.log(Boolean(str1)); //true
      //   console.log(Boolean(str2)); //false

      //   var a = 123,
      //     b = 0,
      //     c = NaN;
      //   console.log(Boolean(a)); //true
      //   console.log(Boolean(b)); //false
      //   console.log(Boolean(c)); //false

      //   var list1 = [1, 2, 3],
      //   list2 = [];
      // console.log(Boolean(list1));  //true
      // console.log(Boolean(list2));  //true

      // console.log(list1 == true);  //false
      // console.log(list2 == true);  //false

      // console.log(list1 == false);  //false
      // console.log(list2 == false);  //true
      
      // 当其他类型与Boolean类型对比时，会将其他类型先转换为数值类型再对比 true---1  false---0

      // console.log(Boolean(undefined));  //false
      // console.log(Boolean(null));   //false
      // console.log(Boolean(NaN));   //false

      // 显示转换
      var a = "";
      console.log(!!a);  //false
      var b=0;
      console.log(!!b);  //false
      var c = null
      console.log(!!a);  //false

    </script>
  </body>
</html>
